import type { ColumnsType } from 'ant-design-vue/lib/table/interface';

import { h } from 'vue';

import { Image } from 'ant-design-vue';

interface DataItem {
  key: number | string;
  username: string;
  email: string;
  t: 0 | 1;
  header_url: string;
  status: 0 | 1;
  create_time: string;
  [key: string]: any; // 添加索引签名
}

const columns: ColumnsType = [
  {
    title: '用户名',
    key: 'username',
    dataIndex: 'username',
    align: 'center',
  },
  {
    title: '邮箱',
    key: 'email',
    dataIndex: 'email',
    align: 'center',
  },
  {
    title: '权限',
    key: 't',
    dataIndex: 't',
    customRender: ({ text }: { text: string }) => {
      return text === '1' ? '管理员' : '普通用户';
    },
    align: 'center',
  },

  {
    title: '是否激活',
    key: 'status',
    dataIndex: 'status',
    customRender: ({ text }: { text: string }) => {
      return text === '1' ? '是' : '否';
    },
    align: 'center',
  },
  {
    title: '创建时间',
    key: 'create_time',
    dataIndex: 'create_time',
    align: 'center',
  },
  {
    title: '头像',
    key: 'header_url',
    dataIndex: 'header_url',
    width: 200,
    customRender: ({ text }: { text: string }) => {
      return h(Image, {
        src: text,
        width: 100,
        height: 50,
        objectFit: 'cover',
      });
    },
    align: 'center',
  },
  {
    title: '修改',
    dataIndex: 'operation',
    width: 200,
    align: 'center',
  },
];

export { columns };
export type { DataItem };
